What is it

Machine learning is basically making software that is able to learn how to do a task without us telling it how to do it.

It's different from normal software that only executes tasks a developer specified through code.

Normal software

For example, we can write a simple instruction that displays the title of a book.

print("Superintelligence");

//Output Below

Superintelligence

That's just a simple instruction that leads to simple output.

New books

With machine learning, we can make software that learns how to write on its own.

It could then write totally new sentences, paragraphs, or even entire books, all on its own.

Circle

Let's look at another example. We could easily write a simple program that can draw a basic shape like a circle.

...
ctx.beginPath();
ctx.arc(X, Y, R, 0, 2 * Math.PI, false);
ctx.lineWidth = 3;
ctx.strokeStyle = '#FF0000';
ctx.stroke();
...

We can see that this is just a few simple lines of code.

Draw a cat

But what if we want to make software that can draw anything? Let's say we told a computer to draw a cat as a first task.

How would we do it?

Take forever

Writing code that explains how to draw one cat would take a very long time. Writing code how to draw in general would take even longer.

Instead, we can show the software what we want, and let it decide which instructions it needs to carry out to draw something.

How?

So we show it an example of a cat, and then it decides what characteristics it needs to replicate.

Data

However, one example isn't enough. It needs a lot of different examples from which it can get information.

The examples we give the software are known as data.

A lot of data

We've learned that for machine learning to work, we have to give the algorithm a lot of data.

With the help of the data, the algorithm figures out how to get to the right output by itself .

Supervised learning

Although the algorithm figures out what steps to take, it needs help knowing when it's right. To do that, we need to train the algorithm.

One common training method is called supervised learning.

Inputs/Outputs

In supervised learning, we show the algorithm many pairs of data. These pairs are made out of inputs and outputs.

Input    |   Output
--------------------
Ireland  |   country
France   |   country
Paris    |   city
  

Awesome! Data pairs can be as simple as these ones or much more complex.

Abstraction

Usually these inputs and outputs end up being very abstract numbers. We won't go into too much detail about how they get abstracted. 

However, let's take a look at a simple example of how the algorithm tries to figure out the correct steps from input to output.

First try

Let's think a bit like an algorithm. We're given a set of values, 4,5,6 as input and 6,7,8 as output. 

We need to change the function result() to get from the input to the output. For a start, let's try adding 1.

def(x):
 print(x+1)

result(4)
result(5)
result(6)

//Output

5
6
7

We can see that the output we have is not the output we want, but we got closer to what we want. Let's tweak the code a bit.

Second try

This time, we'll try something different. Remember, the output should be 6,7,8.

def(x):
 print(x+2)

result(4)
result(5)
result(6)

//Output

6
7
8

That's it! We just needed to figure out steps we need to take to get the desired output. The answer is adding 2.

Easy way

That was a straightforward example that required only a few steps.

Algorithms go through many more examples of data and try thousands of ways to achieve the desired output.

Final note

As a final note, it's good to know that because algorithms work with abstract data and figure out their own ways of achieving a result...

 ... it's possible that humans aren't able to understand the solutions they develop or even know why they work.

Unsupervised learning

Another way of training an algorithm is through unsupervised learning.

Algorithms that are trained this way can find patterns between data and create their own categories.

No output

Compared to supervised learning, we don't need to provide any desired output, only input.

Input    |   Output
--------------------
Ireland  |   -
France   |   -
Paris    |   -
  

Perfect. When using unsupervised learning, we don't need to specify any output.

Unlabelled

Data with no specified features is called unlabelled data.

Since we don't have labels, we don't have any clear goals. This means it's hard to compare unsupervised learning algorithms with other ones.

Simple example

Let's look at an elementary example. What would be a good number of categories for the following numbers?

numbers = [-2,4,5,3.14,-5000]
  • 3

Exactly! We can see that we have negative numbers, positive numbers, and decimals as categories.

Uses

Unsupervised learning can be beneficial for things like learning about user behavior and characteristics when developing apps.

With enough data, it's possible to split up users into categories such as education, age, and time of use among many others.